{include file="public/_header"}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form toolbar">

            </form>
            <table id="tableContainer" lay-filter="tableContainer"></table>
        </div>
    </div>
</div>
{include file="public/_footer"}
<script>
    layui.use(['layer', 'form', 'admin', 'table'],function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
        var table = layui.table;
        initTable();
        function initTable() {
            var url = '{:url("getData")}';
            var insTb = table.render({
                elem: '#tableContainer',
                url: url,
                toolbar: ['<p>',
                    '<button lay-event="add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>{:dictionary("add")}</button>&nbsp;',
                    '</p>'].join(''),
                cols: [[
                    {
                        field:'id',title:"ID",width:'5%'
                    },
                    {
                        field:'title',title:"{:dictionary('dictionary.title')}",width:'10%',
                    },
                    {
                        field:'type',title:"{:dictionary('dictionary.type')}",width:'10%',
                    },
                    {
                        field:'value',title:"{:dictionary('dictionary.title')}",width:'10%'
                    },
                    {
                        field:'value_en',title:"{:dictionary('dictionary.title_en')}",width:'10%'
                    },
                    {
                        field:'value_jp',title:"{:dictionary('dictionary.title_jp')}",width:'10%'
                    },
                    {
                        field:'value_kr',title:"{:dictionary('dictionary.title_kr')}",width:'10%'
                    },
                    {
                        field:'create_time', title:"{:dictionary('create_time')}",width:'15%'
                    },
                    {
                        fixed:'right', title:"{:dictionary('operate')}", width: '20%', align:'center', toolbar: '#barDemo'
                    }
                ]]
            });
        }

        table.on('tool(tableContainer)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){
                del(data.id);
            }else if(obj.event === 'edit') {
                window.location.href = "{:url('edit')}?id=" + data.id;
            }
        });

        table.on('toolbar(tableContainer)', function (obj) {
            if (obj.event === 'add') { // 添加
                window.location.href = "add.html";
            }
        });
    });
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">{:dictionary('edit')}</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">{:dictionary('delete')}</a>
</script>
